//
//  FileDownloadTask.m
//  iphone.mobileoa
//
//  Created by 李亚春 on 13-6-4.
//  Copyright (c) 2013年 Epoint. All rights reserved.
//

#import "FileDownloadTask.h"
#import "FileDownloadModel.h"
#import "HttpUtil.h"


@implementation FileDownloadTask
{
    UIView *cview;
}
-(void)execute
{
    FileDownloadModel *m = [self.params objectForKey:@"model"];
    NSString *folderguid = [self.params objectForKey:@"folerguid"];
    NSData *backData = [HttpUtil getHttpData:m.url];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSString *savePath = [NSString stringWithFormat:@"%@/Documents/attaches/%@/%@",NSHomeDirectory(),folderguid,m.fileName];
    NSString *Dir = [NSString stringWithFormat:@"%@/Documents/attaches/%@/",NSHomeDirectory(),folderguid];
    cview = [self.params objectForKey:@"cview"];
    [fileManager createDirectoryAtPath:Dir withIntermediateDirectories:YES attributes:nil error:nil];
    [fileManager createFileAtPath:savePath contents:backData attributes:nil];
    [self sendDataRefreshUI:savePath];
}



@end
